//
//  JKDrawerScrollView.swift
//  ZhiHuDaily-Swift
//
//  Created by albert on 2018/3/2.
//  Copyright © 2018年 安永博. All rights reserved.
//

import UIKit

class JKDrawerScrollView: UIScrollView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initialization()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        initialization()
    }
    
    private func initialization() {
        
        panGestureRecognizer.maximumNumberOfTouches = 1
    }
    
    override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
        
        let hitView = super.hitTest(point, with: event)
        
        if (point.x > JKScreenW * 6 / 5) {
            
            self.isScrollEnabled = false
            
        } else {
            
            self.isScrollEnabled = true
        }
        
        return hitView;
    }
    
    override func didMoveToSuperview() {
        super.didMoveToSuperview()
        
        guard let _ = superview else { return }
        
        panGestureRecognizer.maximumNumberOfTouches = 1
    }
}
